package com.example.day45.eventbus;

import android.support.v4.app.Fragment;
import android.widget.TextView;

import com.example.day45.R;

import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.EFragment;
import org.androidannotations.annotations.ViewById;
import org.simple.eventbus.EventBus;
import org.simple.eventbus.Subscriber;
import org.simple.eventbus.ThreadMode;

@EFragment(R.layout.fragment_msg1)
public class Msg1Fragment extends Fragment {
    @ViewById
    TextView msgTv;
    EventBus eventBus = EventBus.getDefault();
    @AfterViews
    public void init() {
        eventBus.register(this);
    }

    @Subscriber
    public void getData(String msg) {
        msgTv.setText(msg);
    }

    @Subscriber(tag = "1", mode = ThreadMode.MAIN)
    public void getInfoByTag(String msg) {
        msgTv.setText(msg);
    }
}
